package com.mcc.app.energy.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.energy.domain.EnergyPwaterStatisitcs;
import com.mcc.app.energy.service.IEnergyPwaterStatisitcsService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 能源水泵用水量统计
 *
 * @author gxy
 * @date 2025-03-25
 */
@Api(tags = "能源水泵用水量统计")
@RestController
@RequestMapping("/energy/pwater")
public class EnergyPwaterStatisitcsController extends BaseController {

    @Autowired
    private IEnergyPwaterStatisitcsService energyPwaterStatisitcsService;

    @ApiOperation("查询能源水泵用水量统计列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('energy:pwater:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<EnergyPwaterStatisitcs>> list(EnergyPwaterStatisitcs energyPwaterStatisitcs) {
        List<EnergyPwaterStatisitcs> list = energyPwaterStatisitcsService.selectEnergyPwaterStatisitcsList(energyPwaterStatisitcs);
        return getDataTable(list);
    }

    @ApiOperation("查询能源水泵用水量统计列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('energy:pwater:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<EnergyPwaterStatisitcs>> page(EnergyPwaterStatisitcs energyPwaterStatisitcs) {
        startPage();
        List<EnergyPwaterStatisitcs> list = energyPwaterStatisitcsService.selectEnergyPwaterStatisitcsList(energyPwaterStatisitcs);
        return getDataTable(list);
    }

    @ApiOperation("获取能源水泵用水量统计详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('energy:pwater:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<EnergyPwaterStatisitcs> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(energyPwaterStatisitcsService.selectEnergyPwaterStatisitcsById(id));
    }

    @ApiOperation("新增能源水泵用水量统计")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('energy:pwater:add')")
    @Log(title = "能源水泵用水量统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody EnergyPwaterStatisitcs energyPwaterStatisitcs) {
        return toAjax(energyPwaterStatisitcsService.insertEnergyPwaterStatisitcs(energyPwaterStatisitcs));
    }

    @ApiOperation("修改能源水泵用水量统计")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('energy:pwater:edit')")
    @Log(title = "能源水泵用水量统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody EnergyPwaterStatisitcs energyPwaterStatisitcs) {
        return toAjax(energyPwaterStatisitcsService.updateEnergyPwaterStatisitcs(energyPwaterStatisitcs));
    }

    @ApiOperation("删除能源水泵用水量统计")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('energy:pwater:remove')")
    @Log(title = "能源水泵用水量统计", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(energyPwaterStatisitcsService.deleteEnergyPwaterStatisitcsByIds(ids));
    }

    @ApiOperation("获取能源实时信息")
    @GetMapping("/getRealTimeInfo")
    public AjaxResult getRealTimeInfo() {
        return AjaxResult.success(energyPwaterStatisitcsService.getRealTimeInfo());
    }

    @ApiOperation("获取能源折线图信息")
    @GetMapping("/getEnergyChartAll")
    public AjaxResult getEnergyChartAll(Date beginTime, Date endTime) {
        return AjaxResult.success(energyPwaterStatisitcsService.getEnergyChartAll(beginTime,endTime));
    }

    @ApiOperation("获取能源历史信息")
    @GetMapping("/getEnergyHistory")
    public AjaxResult getEnergyHistory(Date beginTime, Date endTime,Integer timeType, Integer pageNum, Integer pageSize) {
        return AjaxResult.success(energyPwaterStatisitcsService.getEnergyHistory(beginTime,endTime,timeType,pageNum,pageSize));
    }
    @ApiOperation("导出能源历史信息")
    @GetMapping("/exportEnergyHistory")
    public AjaxResult exportEnergyHistory(Date beginTime, Date endTime, Integer timeType) {
        return AjaxResult.success(energyPwaterStatisitcsService.exportEnergyHistory(beginTime, endTime, timeType));
    }
}
